package yxy.game.pm2.module.kow;

import yxy.cherry.data.DataCenter;
import yxy.cherry.data.bean.txdyjingcai;
import yxy.game.pm2.module.kow.KowHandle.KowFinalCode;

/** 决赛对战 */
public class KowFinal {
	private KowFinalCode finalCode;
	private KowFinalPlayer player1;
	private KowFinalPlayer player2;
	private KowFinalPlayer winner;
	private String record;// 录像码

	public KowFinalCode getFinalCode() {
		return finalCode;
	}

	public void setFinalCode(KowFinalCode finalCode) {
		this.finalCode = finalCode;
	}

	public KowFinalPlayer getPlayer1() {
		return player1;
	}

	public void setPlayer1(KowFinalPlayer player1) {
		this.player1 = player1;
	}

	public KowFinalPlayer getPlayer2() {
		return player2;
	}

	public void setPlayer2(KowFinalPlayer player2) {
		this.player2 = player2;
	}

	public KowFinalPlayer getWinner() {
		return winner;
	}

	public void setWinner(KowFinalPlayer winner) {
		this.winner = winner;
	}

	public String getRecord() {
		return record;
	}

	public void setRecord(String record) {
		this.record = record;
	}

	// func======================================

	public KowFinalPlayer player(String playerCode) {
		if (getPlayer1().getPlayerCode().equals(playerCode)) {
			return getPlayer1();
		}
		if (getPlayer2().getPlayerCode().equals(playerCode)) {
			return getPlayer2();
		}
		return null;
	}

	/** 找对手 */
	public KowFinalPlayer oppo(String playerCode) {
		if (getPlayer1().getPlayerCode().equals(playerCode)) {
			return getPlayer2();
		}
		if (getPlayer2().getPlayerCode().equals(playerCode)) {
			return getPlayer1();
		}
		return null;
	}

	public txdyjingcai data() {
		int dataId = 101;
		switch (finalCode) {
		case F1256:
		case F3478:
			dataId = 102;
			break;
		case FINAL:
			dataId = 103;
			break;
		default:
			dataId = 101;
			break;
		}
		txdyjingcai data = DataCenter.getData(dataId, txdyjingcai.class);
		return data;
	}

}
